
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php if (!session_id()) session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>电子商务售前单</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="demo.css" rel="stylesheet" type="text/css" />
    <script src="scripts/boot.js" type="text/javascript"></script>
	<style>

	</style>
    
</head>
<body >

 <fieldset id="fd1" style="border: 1px solid gray;height: 100px">
        <legend><span>搜索</span></legend>
        <div  id='fm1'>
        <div class="fieldset-body">
       客户代码:  <div class="mini-autocomplete" style="width:250px;"  popupWidth="400" textField="id" valueField="id"  id='U_CardCode' name='U_CardCode'
        url="/sale/getOCRDByCode" value="" text=""  onvaluechanged="">     
        <div property="columns">
            <div header="客户代码" field="id" width="30"></div>
            <div header="客户名称" field="text"></div>
        </div>
    </div>
    
           客户名称:  <div class="mini-autocomplete" style="width:250px;"  popupWidth="400" textField="text" valueField="text" 
        url="/sale/getOCRDbyName" value="" text=""  onvaluechanged="" id='U_CardName' name = 'U_CardName'>      
        <div property="columns">
            <div header="客户代码" field="id" width="30"></div>
            <div header="客户名称" field="text"></div>
        </div>
    </div>
            买家姓名： <input id="U_Cstname"  name="U_Cstname" class="mini-textbox" />
            手机号码： <input  id="U_Phone"  name="U_Phone" class="mini-textbox"  value="" /><br/><br/>
            订单号： <input  id="orderId"  name="orderId" class="mini-textbox"  value="" />     
          <a class="mini-button" onclick="search" enabled="" >&nbsp;&nbsp;查询&nbsp;&nbsp;</a>   
        </div>
          </div>
    </fieldset>
  
   
    <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
    buttons="#tabsButtons"
>
    <div title="售后明细" >
   
   <div id="datagrid1" class="mini-datagrid" style="height:160px;width: 100%;" 
        url="" idField="id"
        allowResize="true" 
        allowCellEdit="true" allowCellSelect="true" multiSelect="true"
        allowCellValid="true" oncellvalidation="" showPager='false'
    >
    
        <div property="columns">
        <div field="DocEntry" vtype=""   headerAlign="center"  >
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            <div field="U_BsEntry" vtype=""   headerAlign="center"  >售前单序号
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>    
            
            
             <div field="U_ItemCode" vtype="required;email"   headerAlign="center"  >投诉物料代码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>    
            
             <div field="U_ItemName" vtype="required;email"   headerAlign="center"  >投诉物料名称
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>           
            
              <div field="U_Dealer"   headerAlign="center"  >售后客服代码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            
             <div field="U_DealerName"  headerAlign="center"  >售后客服名称
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            
            
            <div field="U_AlloStatus" vtype=""   headerAlign="center"  renderer="onGenderU_AlloStatus" >分配状态
              <input property="editor" class="mini-combobox" style="width:100%;" data="U_AlloStatus"/>   
            </div>    
            
               <div field="U_Priority"  width="100" renderer="onGenderU_Priority" align="center" headerAlign="center">优先级
                <input property="editor" class="mini-combobox" style="width:100%;" data="U_Priority"/>                
            </div>
            
            
               <div field="U_AccuName"  width="100"  align="center" headerAlign="center">投诉次数描述
                <input property="editor" class="mini-combobox" style="width:100%;" data="Genders"/>                
            </div>
            
            
              <div field="U_AccuQCLs"  width="100" renderer="onGenderU_AccuQCLs" align="center" headerAlign="center">投诉问题大类
                <input property="editor" class="mini-combobox" style="width:100%;" data="U_AccuQCLs"/>                
            </div>
            
            
            
            <div field="U_AccuDate"     >投诉日期
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'   format="yyyy-MM-dd" />                
            </div>
              <div field="U_AccuTime"     >投诉时间
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'  format=" Hmm"  timeFormat="H:mm" showTime="true" />                
            </div>
            
              
            <div field="U_AccuTel" vtype="required;email"   headerAlign="center"  >投诉人电话号码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
              
            <div field="U_AccuPers" vtype="required;email"   headerAlign="center"  >投诉人
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            
            <div field="U_AccuDetl" vtype="required;email"   headerAlign="center"  >售后问题描述
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
              
               <div field="U_AccuQDtl" vtype="required;email"   headerAlign="center"  >售前问题描述
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
              
              
                <div field="U_CustAdr" vtype="required;email"   headerAlign="center"  >客户地址
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
              <div field="U_QSummary" vtype="required;email"   headerAlign="center"  >问题总结
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
               <div field="U_ProSts"  width="100" renderer="onGenderRenderer" align="center" headerAlign="center">处理状态
                <input property="editor" class="mini-combobox" style="width:100%;" data="Genders"/>                
            </div>
            
            <div field="U_ProEndDate"     >处理结束日期
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'   format="yyyy-MM-dd" />                
            </div>
              <div field="U_ProEndTime"     >处理结束时间
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'  format=" Hmm"  timeFormat="H:mm" showTime="true" />                
            </div>
            
          
        </div>
    </div>
    
    
    
    </div>
    <!-- <div title="Tab2" iconCls="" >
        2
    </div> -->
</div>

  <div id='editForm1'>
    售前问题描述：<textarea class="mini-textarea" emptyText="" style="width: 30%;margin-top: 5px" id='U_AccuQDtl' name='U_AccuQDtl'></textarea> <br />
    售后问题描述：<textarea class="mini-textarea" emptyText="" style="width: 30%;margin-top: 5px"id='U_AccuDetl' name='U_AccuDetl'></textarea> <br />
     创建人&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <input id="U_Suggest"  name="username" class="mini-textbox"   name='U_Suggest'  />
    <br />
      <a class="mini-button" onclick="search" enabled="" id='query-bt' >&nbsp;&nbsp;查找&nbsp;&nbsp;</a>
    <a class="mini-button" onclick="save" enabled="" id='update-bt' style="display: none">&nbsp;&nbsp;更新&nbsp;&nbsp;</a>
    <a class="mini-button" onclick="clear" enabled="" id='colse-tb'>&nbsp;&nbsp;取消&nbsp;&nbsp;</a>
  </div>
</body>
<script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        var grid = mini.get("datagrid1");
        var Genders = [{'id':'1','text':'未完成'},{'id':'2','text':'处理中'},{'id':'3','text':'已完成'}];
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
        var U_AccuQCLs = [{'id':'1','text':'1--质量问题'},{'id':'2','text':'2--快递运输问题'},{'id':'3','text':'3--发票问题'},{'id':'4','text':'4--商品信息问题'},{'id':'5','text':'5--发货问题'},{'id':'6','text':'5--其他'},{'id':'0','text':'0-- -'}];
        
        function onGenderU_AccuQCLs(e) {
            for (var i = 0, l = U_AccuQCLs.length; i < l; i++) {
                var g = U_AccuQCLs[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }


     var U_Priority = [{'id':'1','text':'1--高'},{'id':'2','text':'2--中'},{'id':'3','text':'3--低'}];
        
        function onGenderU_Priority(e) {
            for (var i = 0, l = U_Priority.length; i < l; i++) {
                var g = U_Priority[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }

	  var U_AlloStatus = [{'id':'Y','text':'已分配'},{'id':'N','text':'未分配'}];
        
        function onGenderU_AlloStatus(e) {
           
            for (var i = 0, l = U_AlloStatus.length; i < l; i++) {
                var g = U_AlloStatus[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
        
        
        ///////////////////////////////////////////////////////
        function removeRow() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                grid.removeRows(rows, true);
            }
        }

        grid.on("cellbeginedit", function (e) {
            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;
            var row = grid.getSelected();
            if(row.U_ProSts==3){
            	e.cancel=true;
                }
            });
        function save() {
        	var data = grid.getChanges()[0];
        	if(data==null){
				mini.alert('无更新数据');
				return;
            }
            
          
             var json = mini.encode(data);      
            var form = new mini.Form("#fm1");            
            var fmdata = form.getData();      //获取表单多个控件的数据
            var U_Suggest = mini.get('U_Suggest').getValue();
            fmdata.U_Suggest=U_Suggest;
            var fmjson = mini.encode(fmdata); //序列化成JSON
            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '保存中...'
            });
            $.ajax({
                url: "/sale/updateCustAjax",
                data: { data: json,fmdata:fmjson},
                type: "post",
                success: function (text) {
                   if(text>0){
                	    mini.unmask(document.body);
						mini.alert('更新成功!');
						search();
						return ;
                   }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

 		var db = new mini.DataBinding();
        
        db.bindForm("editForm1", grid);
        function search(){
			var khcode = mini.get('U_CardCode').getValue();
			var orderId = mini.get('orderId').getValue();
	            var form = new mini.Form("#fm1");            
	            var fmdata = form.getData();     
			 if(fmdata.U_CardCode==''&&fmdata.U_CardName==''&&fmdata.U_Cstname==''&&fmdata.orderId==''&&fmdata.U_Phone==''){
					alert('请输入至少一个查询条件');
					return ;
	             } 

			 var fmjson = mini.encode(fmdata); //序列化成JSON
			  mini.mask({
	               el: document.body,
	               cls: 'mini-mask-loading',
	               html: '数据加载中....'
	           }); 
	            
      	  $.ajax({
              url: "/sale/getCustdataAjax",
              data: { orderId: orderId,fmjson:fmjson },
              type: "post",
              dataType:'json',
              success: function (data) {
            	 
            	  grid.setData(data.preData);
            	  if(!data.preData){
            	    mini.unmask(document.body);
					mini.alert('没有找到记录');
					return;
                	}
				
            	 /*  for(var i=0;i<data.preData.length;i++){
            		  grid.getRow(i).cancel=true;
					} */
    				jQuery('#query-bt').hide();
    				jQuery('#update-bt').show();
   				    mini.unmask(document.body);
              },
              error: function (jqXHR, textStatus, errorThrown) {
                  alert(jqXHR.responseText);
              }
          });

            }

        function clear(){
       	 grid.setData(null);
         }
      

    </script>

</html>